<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      font-size: 28px;
    }
  </style>
  <link rel="prerender"
    href="./ifr.html">
</head>

<body>

  我是主页面

  <div>
    <button type="button" id="btnCreate">创建iframe</button>
  </div>
  <script>
    btnCreate.onclick = function () {
      var el = document.createElement("iframe");
      el.src = "./ifr.html";
      document.body.append(el);
    }
  </script>

</body>

</html>